package com.crm.business.admin.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.crm.business.crm.service.IBillCrmTrainingService;
import com.crm.common.annotation.RepeatSubmit;
import com.crm.common.crm.entity.BO.BillCrmTrainingBO;
import com.crm.common.crm.entity.PO.BillCrmTraining;
import com.crm.common.ka.core.common.R;
import com.crm.common.ka.core.common.Result;
import com.crm.common.ka.core.common.log.BehaviorEnum;
import com.crm.common.ka.core.common.log.SysLogHandler;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/adminTraining")
@Api(tags = "训练营模式")
@Slf4j
public class BillAdminTrainingController {

    @Autowired
    private IBillCrmTrainingService billCrmStudentPoolService;

    @PostMapping("/queryPageList")
    @ApiOperation("查询列表页数据")
    public Result<IPage<BillCrmTraining>> queryPageList(@RequestBody BillCrmTrainingBO crmTrainingBO) {
        IPage<BillCrmTraining> poolPage = billCrmStudentPoolService.queryPageList(crmTrainingBO);
        return R.ok(poolPage);
    }

    @GetMapping("/queryById/{id}")
    @ApiOperation("查询详细")
    public Result<BillCrmTraining> queryById(@PathVariable("id") Integer id){
        return  billCrmStudentPoolService.queryById(id);
    }


    @PostMapping("/update")
    @ApiOperation("更新数据")
    @SysLogHandler(behavior = BehaviorEnum.UPDATE)
    @RepeatSubmit
    public Result<Map<String, Object>> update(@RequestBody BillCrmTraining crmTraining){
        return  billCrmStudentPoolService.update(crmTraining);
    }

    @GetMapping("/queryTrainingStatus")
    @ApiOperation("查询详细")
    public Result queryTrainingStatus(){
        return  billCrmStudentPoolService.queryTrainingStatus();
    }

}
